package per.example.arpproject.service;

import org.springframework.web.multipart.MultipartFile;
import per.example.arpproject.entity.Script;
import per.example.arpproject.entity.ScriptDetail;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author yaozhang Li
 * @ TO DO
 * @createTime 2023/7/10 19:38
 **/
public interface ScriptService {

    /**
     * 获取所有脚本名称
     *
     * @author: yaozhang Li
     * @date: 2023/7/10 19:46
     * @param:
     * @return: java.util.List<per.example.arpproject.entity.Script>
     */
    List<Script> getAllScript();

    /**
     * 新增脚本
     *
     * @author: yaozhang Li
     * @date: 2023/7/10 19:47
     * @param: entity
     * @return: int
     */
    int addScript(Script entity);

    /**
     * 更新脚本名称
     *
     * @author: yaozhang Li
     * @date: 2023/7/10 19:49
     * @param: entity
     * @return: int
     */
    int updateScript(Script entity);

    /**
     * 删除脚本
     *
     * @author: yaozhang Li
     * @date: 2023/7/10 19:49
     * @param: id
     * @param deleteFile 是否删除文件
     * @return: int
     */
    int deleteScript(Long id,Boolean deleteFile);

    /**
     * 获取详情
     *
     * @author: yaozhang Li
     * @date: 2023/7/10 19:49
     * @param: id
     * @return: per.example.arpproject.entity.ScriptDetail
     */
    ScriptDetail getDetailById(Long id);

    /**
     * 更新详情
     *
     * @author: yaozhang Li
     * @date: 2023/7/10 19:50
     * @param: entity
     * @return: int
     */
    int updateDetailById(ScriptDetail entity);

    /**
     * 为脚本上传图片
     *
     * @author: yaozhang Li
     * @date: 2023/7/10 19:50
     * @param: file
     * @param: id
     * @return: java.lang.String
     */
    String uploadScriptImg(MultipartFile file, Long id);


    /**
     * 导出脚本文件
     *
     * @author: yaozhang Li
     * @date: 2023/7/10 19:51
     * @param: id
     * @param: httpServletResponse
     * @param: httpServletRequest
     * @param: withEnv
     * @return: void
     */
    void exportScript(Long id,String withEnv, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException;

    /**
     * 为脚本文件上传图片
     *
     * @author: yaozhang Li
     * @date: 2023/7/12 19:26
     * @param: scriptId
     * @param: file
     * @return: void
     */
    String uploadPict(Long scriptId, MultipartFile file) throws IOException;

    /**
     * 导入脚本数据
     *
     * @author: yaozhang Li
     * @date: 2023/8/3 16:15
     * @param: file
     * @param: name
     * @return: void
     */
    void importScript(MultipartFile file, String name);
}
